class File{
public:
    string line;
    ifstream readFile;  
    ofstream writeFile;

    void Open(string source,string source2){
        readFile.open(source);
        writeFile.open(source2);
        if (readFile.is_open() && writeFile.is_open())
        cout << "////FILES OPEN/////" << endl;
        else
        cout << "/////UNABLE TO OPEN THE FILES/////"; 
    }    
    void RemoveComents(){
         if (readFile.is_open() && writeFile.is_open()){
             while ( readFile.good() ){
                 getline (readFile,line);
                 bool coment = false;///to know if is a long coment or a short one
                 if(line.find("//") < 4294967295){///look for the coment tags
                     bool insert = false;
                     if(line.find("//*")< 4294967295)
                         coment=true;
                        writeFile << line.substr (0,line.find("//"));

                        
                     while(coment==true){
                         if(line.find("*//")< 4294967295){
                            coment=false;
                            writeFile << line.substr (line.find("*//")+3);
                        }else if (readFile.good()) {
                             getline (readFile,line);
                        }else{
                            cout <<"ERROR CHECK YOUR COMENT TAGS";
                            coment=false;
                        }
                     }

                        writeFile << endl;
                 }else
                     writeFile << line << endl;
             }
        }else cout << "/////UNABLE TO OPEN THE FILES/////"; 
    }
    void RemoveSpaces(){
        while ( readFile.good() ){
                cout << readFile.read("",1);
        }
    }

    void Close(){
        readFile.close();
        writeFile.close();
        cout << "////FILES CLOSED////" << endl;
    }
};
int main(){
    File file;
    file.Open("C:/Users/german/Desktop/prueva.hwe","C:/Users/german/Desktop/noComents.hwe");
    file.RemoveComents();
    file.Close();
    cin.get();
    return 0;
}
